function [model]=M_step(model, data, MAXMSTEPITER, MaxFun, maxvalue, countVEM)


MINDIFF   = 0.005;
conv_diff = 100000000;
count     = 0;



model=update_alpha_01(model);
value1 = cal_likelihood(model, data);

if (compareval(value1, maxvalue))
    maxvalue = value1;
    %disp('correct');
else
    disp('Incorrect');
    keyboard;
end


model=update_beta (model, data);
value2 = cal_likelihood(model, data);

if (compareval(value2, maxvalue))
    maxvalue = value2;
    %disp('correct');
else
    disp('Incorrect');
    keyboard;
end

model=update_sigma_01(model);
value3 = cal_likelihood(model, data);

if (compareval(value3, maxvalue))
    maxvalue = value3;
    %disp('correct');
else
    disp('Incorrect');
    keyboard;
end


value0 = maxvalue;

while(conv_diff>MINDIFF && count<MAXMSTEPITER)
    
    disp('count from M-step');
    count = count+1
    
    model=update_alpha_02(model);
    value4 = cal_likelihood(model, data);
    
    if (compareval(value4, maxvalue))
        maxvalue = value4;
        %disp('correct');
    else
        disp('Incorrect');
        keyboard;
    end
    
    
    model=update_sigma_02(model, MaxFun);
    value5 = cal_likelihood(model, data);
    
    if (compareval(value5, maxvalue))
        maxvalue = value5;
        %disp('correct');
    else
        disp('Incorrect');
        keyboard;
    end
    
    model=update_eta(model, MaxFun);
    value6 = cal_likelihood(model, data);
    
    if (compareval(value6, maxvalue))
        maxvalue = value6;
        %disp('correct');
    else
        disp('Incorrect');
        keyboard;
    end
    
    conv_diff=abs(value6-value0)/abs(value6);
    value0=value6;
    
end

end
